/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package sqlitedb;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.sql.Statement;

/**
 *
 * @author kylin
 */
public class Demo0002_CreateDB {
    public static void main(String[] args){
        Connection connection = null;
        try{
            connection = DriverManager.getConnection("jdbc:sqlite:sample.db");//使用相对路径创建，如果数据库不存在则自动创建
            //connection = DriverManager.getConnection("jdbc:sqlite:E:\\sample.db");//使用绝对路径创建，如果数据库不存在则自动创建
            Statement statement = connection.createStatement();
            statement.setQueryTimeout(30);
        }catch(SQLException e){
            System.err.println(e.getMessage());
        }finally{
            try{
                if(connection != null){
                    connection.close();
                }
            }catch(SQLException e){
                System.err.println(e);
            }
        }
    }
}
